//
//  OtherTableCell.swift
//  TrafficViolation
//
//  Created by eaglelive on 2017/6/19.
//  Copyright © 2017年 eaglelive. All rights reserved.
//

import Foundation
class OtherTableCell: UITableViewCell {
    let cellH:CGFloat = 40
    var orderNo,ostatus,subUser,subTime: UILabel!
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCellSelectionStyle.none
        self.backgroundColor = tableBgColor
        self.setupMainView()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func setupMainView() {
        // 背景view
        let backgroundView = UIView()
        backgroundView.layer.borderColor = colorFromHex(0xeeeeee).cgColor
        backgroundView.layer.borderWidth = 1
        backgroundView.layer.cornerRadius = 5
        backgroundView.layer.masksToBounds = true
        backgroundView.backgroundColor = UIColor.white
        self.addSubview(backgroundView)
        backgroundView.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(5)
            make.top.equalTo(self).offset(5)
            make.right.equalTo(self).offset(-5)
            make.bottom.equalTo(self)
        }
        orderNo = UILabel()
        orderNo.font = UIFont.systemFont(ofSize: 13)
        backgroundView.addSubview(orderNo)
        orderNo.snp.makeConstraints { (make) in
            make.height.equalTo(35)
            make.top.equalTo(backgroundView)
            make.left.equalTo(backgroundView).offset(5)
            make.width.equalTo(200)
        }
        ostatus = UILabel()
        ostatus.textColor = appMainColor
        ostatus.font = UIFont.systemFont(ofSize: 13)
        backgroundView.addSubview(ostatus)
        ostatus.snp.makeConstraints { (make) in
            make.top.equalTo(backgroundView)
            make.right.equalTo(backgroundView).offset(-5)
            make.height.equalTo(35)
        }
        //长分割线
        let longSeparator = UILabel()
        longSeparator.backgroundColor = appMainColor
        backgroundView.addSubview(longSeparator)
        longSeparator.snp.makeConstraints { (make) in
            make.height.equalTo(1)
            make.top.equalTo(orderNo.snp.bottom).offset(1)
            make.left.equalTo(backgroundView).offset(5)
            make.right.equalTo(backgroundView).offset(-5)
        }
        subUser = UILabel()
        subUser.font = UIFont.systemFont(ofSize: 13)
        subUser.lineBreakMode = .byTruncatingMiddle
        backgroundView.addSubview(subUser)
        subUser.snp.makeConstraints { (make) in
            make.bottom.equalTo(backgroundView)
            make.left.equalTo(backgroundView).offset(5)
            make.height.equalTo(35)
        }
        subTime = UILabel()
        subTime.font = UIFont.systemFont(ofSize: 13)
        backgroundView.addSubview(subTime)
        subTime.snp.makeConstraints { (make) in
            make.bottom.equalTo(backgroundView)
            make.right.equalTo(backgroundView).offset(-5)
            make.height.equalTo(35)
        }
    }
    func configCellDateWithModel(_ model:OtherModel) {
        orderNo.text = "订单号：\(model.orderNo)"
        var oTitle = ""
        if "otherOrder" == model.opeType {
            if "0" == model.ostatus {
                oTitle = "未支付"
            }
            if "1" == model.ostatus {
                oTitle = "待处理"
            }
            if "2" == model.ostatus {
                oTitle = "处理中"
            }
            if "3" == model.ostatus {
                oTitle = "完成"
            }
        }else if "oprocessOrder" == model.opeType {
            if "" == model.oprocess{
                oTitle = "待审核"
            }else if "0" == model.oprocess {
                oTitle = "不可办"
            }else{
                if "0" == model.ostatus {
                    oTitle = "未支付"
                }
                if "1" == model.ostatus {
                    oTitle = "待处理"
                }
                if "2" == model.ostatus {
                    oTitle = "处理中"
                }
                if "3" == model.ostatus {
                    oTitle = "完成"
                }
            }
        }else if "insuranceOrder" == model.opeType {
            if "" == model.isOriginals {//判断是否需要上传车身照片
                oTitle = "待审核"
            }else{
                if "0" == model.ostatus {
                    oTitle = "未支付"
                }
                if "1" == model.ostatus {
                    oTitle = "待处理"
                }
                if "2" == model.ostatus {
                    oTitle = "处理中"
                }
                if "3" == model.ostatus {
                    oTitle = "完成"
                }
            }
        }
        ostatus.text = oTitle
        subUser.text = "下单人：\(model.subUser)"
        subTime.text = "下单时间：\(model.subTime)"
    }
}
